/**
 */
package usixmlcui.impl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import usixmlcui.Color;
import usixmlcui.ConcreteGraphicalStyle;
import usixmlcui.Usixml_cuiPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Color</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link usixmlcui.impl.ColorImpl#getRed <em>Red</em>}</li>
 *   <li>{@link usixmlcui.impl.ColorImpl#getGreen <em>Green</em>}</li>
 *   <li>{@link usixmlcui.impl.ColorImpl#getBlue <em>Blue</em>}</li>
 *   <li>{@link usixmlcui.impl.ColorImpl#getAlpha <em>Alpha</em>}</li>
 *   <li>{@link usixmlcui.impl.ColorImpl#getBorderColor <em>Border Color</em>}</li>
 *   <li>{@link usixmlcui.impl.ColorImpl#getForegroundColor <em>Foreground Color</em>}</li>
 *   <li>{@link usixmlcui.impl.ColorImpl#getBackgroundColor <em>Background Color</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ColorImpl extends EObjectImpl implements Color {
	/**
	 * The default value of the '{@link #getRed() <em>Red</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRed()
	 * @generated
	 * @ordered
	 */
	protected static final int RED_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getRed() <em>Red</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRed()
	 * @generated
	 * @ordered
	 */
	protected int red = RED_EDEFAULT;

	/**
	 * The default value of the '{@link #getGreen() <em>Green</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGreen()
	 * @generated
	 * @ordered
	 */
	protected static final int GREEN_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getGreen() <em>Green</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGreen()
	 * @generated
	 * @ordered
	 */
	protected int green = GREEN_EDEFAULT;

	/**
	 * The default value of the '{@link #getBlue() <em>Blue</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBlue()
	 * @generated
	 * @ordered
	 */
	protected static final int BLUE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getBlue() <em>Blue</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBlue()
	 * @generated
	 * @ordered
	 */
	protected int blue = BLUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getAlpha() <em>Alpha</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAlpha()
	 * @generated
	 * @ordered
	 */
	protected static final float ALPHA_EDEFAULT = 0.0F;

	/**
	 * The cached value of the '{@link #getAlpha() <em>Alpha</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAlpha()
	 * @generated
	 * @ordered
	 */
	protected float alpha = ALPHA_EDEFAULT;

	/**
	 * The cached value of the '{@link #getBorderColor() <em>Border Color</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBorderColor()
	 * @generated
	 * @ordered
	 */
	protected ConcreteGraphicalStyle borderColor;

	/**
	 * The cached value of the '{@link #getForegroundColor() <em>Foreground Color</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getForegroundColor()
	 * @generated
	 * @ordered
	 */
	protected ConcreteGraphicalStyle foregroundColor;

	/**
	 * The cached value of the '{@link #getBackgroundColor() <em>Background Color</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBackgroundColor()
	 * @generated
	 * @ordered
	 */
	protected ConcreteGraphicalStyle backgroundColor;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ColorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return Usixml_cuiPackage.Literals.COLOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getRed() {
		return red;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRed(int newRed) {
		int oldRed = red;
		red = newRed;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.COLOR__RED, oldRed, red));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getGreen() {
		return green;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGreen(int newGreen) {
		int oldGreen = green;
		green = newGreen;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.COLOR__GREEN, oldGreen, green));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getBlue() {
		return blue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBlue(int newBlue) {
		int oldBlue = blue;
		blue = newBlue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.COLOR__BLUE, oldBlue, blue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public float getAlpha() {
		return alpha;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAlpha(float newAlpha) {
		float oldAlpha = alpha;
		alpha = newAlpha;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.COLOR__ALPHA, oldAlpha, alpha));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalStyle getBackgroundColor() {
		if (backgroundColor != null && backgroundColor.eIsProxy()) {
			InternalEObject oldBackgroundColor = (InternalEObject)backgroundColor;
			backgroundColor = (ConcreteGraphicalStyle)eResolveProxy(oldBackgroundColor);
			if (backgroundColor != oldBackgroundColor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Usixml_cuiPackage.COLOR__BACKGROUND_COLOR, oldBackgroundColor, backgroundColor));
			}
		}
		return backgroundColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalStyle basicGetBackgroundColor() {
		return backgroundColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBackgroundColor(ConcreteGraphicalStyle newBackgroundColor) {
		ConcreteGraphicalStyle oldBackgroundColor = backgroundColor;
		backgroundColor = newBackgroundColor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.COLOR__BACKGROUND_COLOR, oldBackgroundColor, backgroundColor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalStyle getForegroundColor() {
		if (foregroundColor != null && foregroundColor.eIsProxy()) {
			InternalEObject oldForegroundColor = (InternalEObject)foregroundColor;
			foregroundColor = (ConcreteGraphicalStyle)eResolveProxy(oldForegroundColor);
			if (foregroundColor != oldForegroundColor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Usixml_cuiPackage.COLOR__FOREGROUND_COLOR, oldForegroundColor, foregroundColor));
			}
		}
		return foregroundColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalStyle basicGetForegroundColor() {
		return foregroundColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setForegroundColor(ConcreteGraphicalStyle newForegroundColor) {
		ConcreteGraphicalStyle oldForegroundColor = foregroundColor;
		foregroundColor = newForegroundColor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.COLOR__FOREGROUND_COLOR, oldForegroundColor, foregroundColor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalStyle getBorderColor() {
		if (borderColor != null && borderColor.eIsProxy()) {
			InternalEObject oldBorderColor = (InternalEObject)borderColor;
			borderColor = (ConcreteGraphicalStyle)eResolveProxy(oldBorderColor);
			if (borderColor != oldBorderColor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, Usixml_cuiPackage.COLOR__BORDER_COLOR, oldBorderColor, borderColor));
			}
		}
		return borderColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConcreteGraphicalStyle basicGetBorderColor() {
		return borderColor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBorderColor(ConcreteGraphicalStyle newBorderColor) {
		ConcreteGraphicalStyle oldBorderColor = borderColor;
		borderColor = newBorderColor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Usixml_cuiPackage.COLOR__BORDER_COLOR, oldBorderColor, borderColor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Usixml_cuiPackage.COLOR__RED:
				return new Integer(getRed());
			case Usixml_cuiPackage.COLOR__GREEN:
				return new Integer(getGreen());
			case Usixml_cuiPackage.COLOR__BLUE:
				return new Integer(getBlue());
			case Usixml_cuiPackage.COLOR__ALPHA:
				return new Float(getAlpha());
			case Usixml_cuiPackage.COLOR__BORDER_COLOR:
				if (resolve) return getBorderColor();
				return basicGetBorderColor();
			case Usixml_cuiPackage.COLOR__FOREGROUND_COLOR:
				if (resolve) return getForegroundColor();
				return basicGetForegroundColor();
			case Usixml_cuiPackage.COLOR__BACKGROUND_COLOR:
				if (resolve) return getBackgroundColor();
				return basicGetBackgroundColor();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Usixml_cuiPackage.COLOR__RED:
				setRed(((Integer)newValue).intValue());
				return;
			case Usixml_cuiPackage.COLOR__GREEN:
				setGreen(((Integer)newValue).intValue());
				return;
			case Usixml_cuiPackage.COLOR__BLUE:
				setBlue(((Integer)newValue).intValue());
				return;
			case Usixml_cuiPackage.COLOR__ALPHA:
				setAlpha(((Float)newValue).floatValue());
				return;
			case Usixml_cuiPackage.COLOR__BORDER_COLOR:
				setBorderColor((ConcreteGraphicalStyle)newValue);
				return;
			case Usixml_cuiPackage.COLOR__FOREGROUND_COLOR:
				setForegroundColor((ConcreteGraphicalStyle)newValue);
				return;
			case Usixml_cuiPackage.COLOR__BACKGROUND_COLOR:
				setBackgroundColor((ConcreteGraphicalStyle)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case Usixml_cuiPackage.COLOR__RED:
				setRed(RED_EDEFAULT);
				return;
			case Usixml_cuiPackage.COLOR__GREEN:
				setGreen(GREEN_EDEFAULT);
				return;
			case Usixml_cuiPackage.COLOR__BLUE:
				setBlue(BLUE_EDEFAULT);
				return;
			case Usixml_cuiPackage.COLOR__ALPHA:
				setAlpha(ALPHA_EDEFAULT);
				return;
			case Usixml_cuiPackage.COLOR__BORDER_COLOR:
				setBorderColor((ConcreteGraphicalStyle)null);
				return;
			case Usixml_cuiPackage.COLOR__FOREGROUND_COLOR:
				setForegroundColor((ConcreteGraphicalStyle)null);
				return;
			case Usixml_cuiPackage.COLOR__BACKGROUND_COLOR:
				setBackgroundColor((ConcreteGraphicalStyle)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Usixml_cuiPackage.COLOR__RED:
				return red != RED_EDEFAULT;
			case Usixml_cuiPackage.COLOR__GREEN:
				return green != GREEN_EDEFAULT;
			case Usixml_cuiPackage.COLOR__BLUE:
				return blue != BLUE_EDEFAULT;
			case Usixml_cuiPackage.COLOR__ALPHA:
				return alpha != ALPHA_EDEFAULT;
			case Usixml_cuiPackage.COLOR__BORDER_COLOR:
				return borderColor != null;
			case Usixml_cuiPackage.COLOR__FOREGROUND_COLOR:
				return foregroundColor != null;
			case Usixml_cuiPackage.COLOR__BACKGROUND_COLOR:
				return backgroundColor != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (red: ");
		result.append(red);
		result.append(", green: ");
		result.append(green);
		result.append(", blue: ");
		result.append(blue);
		result.append(", alpha: ");
		result.append(alpha);
		result.append(')');
		return result.toString();
	}

} //ColorImpl
